package test;

import java.util.Scanner;
//字符串变形
public class topic08 {
    public static void main(String[] args) {
        System.out.println("输入字符串");
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        System.out.println("输入长度");
        int length = sc.nextByte();
        String[] split = str.split(" ");
        String newstr = "";
        for (int i = split.length - 1 ; i >= 0 ; i--) {
            if (i>0){
                newstr += split[i] + " "; }
            else{
                newstr += split[i]; }
        }
        char[] cs = newstr.toCharArray();
        StringBuffer tranBuffer = new StringBuffer();
        for (char c : cs) {
            if (c>='a'&& c<='z') {
                tranBuffer.append(Character.toUpperCase(c));
            } else if (c>='A'&& c<='Z') {
                tranBuffer.append(Character.toLowerCase(c));
            } else {
                tranBuffer.append(c); }
        }
        System.out.println(tranBuffer.toString());
    }
}
